<template>
  <div id="app">
    <button @click="show = true">显示对话框</button>
    <!-- 文本 -->
    <!-- <el-dialog title="对话框" :visible.sync="show" width="30%" >
      <span>这是一段文本</span>
      <span slot="footer">
        <el-button @click="show = false">Cancel</el-button>
        <el-button type="primary" @click="handleOk">OK</el-button>
      </span>
    </el-dialog> -->
    <!-- 表格 -->
    <!-- <el-dialog title="对话框" :visible.sync="show" width="30%">
      <el-table :data="tableData">
        <el-table-column label="id" prop="id"></el-table-column>
        <el-table-column label="name" prop="title"></el-table-column>
      </el-table>
      <span slot="footer">
        <el-button @click="show = false">Cancel</el-button>
        <el-button type="primary" @click="handleOk">OK</el-button>
      </span>
    </el-dialog> -->

    <!-- 表单 -->
    <el-dialog title="对话框" :visible.sync="show">
      <el-form :model="form">
        <el-form-item label="名称" label-width="80px">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <!-- 下拉菜单  -->
        <el-form-item label="下拉菜单" label-width="80px">
          <el-select v-model="form.selectValue">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer">
        <el-button @click="show = false">Cancel</el-button>
        <el-button type="primary" @click="handleOk">OK</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "App",
  components: {},
  data: function () {
    return {
      show: false,
      form: {
        name: "Tom",
        selectValue: "",
      },
      options: [
        {
          value: 1,
          label: "猫",
        },
        {
          value: 2,
          label: "老鼠",
        },
        {
          value: 3,
          label: "狗",
        },
      ],
      tableData: [
        {
          id: 1,
          title: "Tom",
        },
        {
          id: 2,
          title: "Jack",
        },
      ],
    };
  },
  methods: {
    handleOk: function () {
      this.show = false;
    },
  },
};
</script>

<style>
</style>
